<!DOCTYPE html>
<html>
<head>
    <title>农商互联开发平台</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>

    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <!--    <script src="/static/js/framework-ui.js"></script>-->
    <!--    <script src="/static/js/framework-clientdata.js"></script>-->

    <!--弹框js-->
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/layui/layui.js"></script>
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/lay/modules/layer.js"></script>


    <!--    配置select多选相关-->
    <!--    <script src="/static/layui/dist/xm-select.js"></script>-->

        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}


</head>
<body>
<style>
    .error {
        display: block;
        color: red
    }

    html, body {
        background-color: #FFF !important;
    }

    .modal-body {
        background-color: #fff;
        padding: 15px
    }

    .page-header {
        margin-top: 15px !important;
    }

    .geographic input {
        width: 100px !important;
        float: left;
        margin-right: 15px;
    }
    .config_img{margin-top:15px;width:100px;}
</style>

<div class="modal-body">


    <div class="page-header">
        <h3>添加党员</h3>
    </div>

    <form class="form-horizontal layui-form">


        <div class="form-group">

            <label class="col-sm-1 control-label">*所属景区:</label>
            <div class="col-sm-2">
                <select name="colony_id" lay-filter="colony_id">
                    {volist name="colony" id="vo"}
                    <option value="{$vo.id}">{$vo.name}</option>
                    {/volist}
                </select>
            </div>

            <label class="col-sm-1 control-label">*关联栏目:</label>
            <div class="col-sm-2">
                <select name="classify_id" lay-filter="classify_id">
                    {volist name="classify" id="vo"}
                    <option value="{$vo.id}" {if condition="$classify_id eq $vo['id']"} selected {/if} >{$vo.name}</option>
                    {/volist}
                </select>
            </div>


            <label class="col-sm-1 control-label">*关联用户:</label>
            <div class="col-sm-2">
                <div class="input-group ">
                    <input type="text" id="user" value="" class="form-control" disabled>
                    <input type="hidden" name="fans_id" value="" class="form-control">
                    <span class="input-group-btn">
                        <button class="btn btn-default" id="user_btn" type="button">选择用户</button>
                    </span>
                </div>
            </div>

        </div>



        <div class="form-group">
            <label class="col-sm-1 control-label">*党员姓名:</label>
            <div class="col-sm-2">
                <input type="text" class="form-control" name="name" placeholder="党员姓名">
                <p class="error"></p>
            </div>

            <label class="col-sm-1 control-label">*性别:</label>
            <div class="col-sm-2">
                <select name="sex">
                    {volist name="sex" id="vo"}
                    <option value="{$key}">{$vo}</option>
                    {/volist}
                </select>
            </div>

            <label class="col-sm-1 control-label">*所属支部:</label>
            <div class="col-sm-2">
                <input type="text" class="form-control" name="branch" placeholder="所属支部">
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-1 control-label">出生年月:</label>
            <div class="col-sm-2">
                <input type="text" class="form-control " name="birth" placeholder="出生年月">
            </div>

            <label class="col-sm-1 control-label">*学历:</label>
            <div class="col-sm-2">
                <select name="schooling">
                    {volist name="schooling" id="vo"}
                    <option value="{$key}">{$vo}</option>
                    {/volist}
                </select>
            </div>

            <label class="col-sm-1 control-label">入党时间:</label>
            <div class="col-sm-2">
                <input type="text" class="form-control test-item" name="party_time" placeholder="入党时间">
            </div>
        </div>

        <div class="form-group">

            <label class="col-sm-1 control-label">党员身份:</label>
            <div class="col-sm-2">
                <select name="account">
                    {volist name="account" id="vo"}
                    <option value="{$key}">{$vo}</option>
                    {/volist}
                </select>
            </div>

            <label class="col-sm-1 control-label">星级:</label>
            <div class="col-sm-2">
                <select name="star_level">
                    {volist name="level" id="vo"}
                    <option value="{$key}">{$vo}</option>
                    {/volist}
                </select>
            </div>


            <label class="col-sm-1 control-label">工作单位:</label>
            <div class="col-sm-2">
                <input type="text" class="form-control " name="work_units" placeholder="工作单位">
            </div>
        </div>

        <div class="form-group">

            <label class="col-sm-1 control-label">积分:</label>
            <div class="col-sm-2">
                <input type="number" name="integral" class="form-control" value="0" >
            </div>

        </div>


        <div class="form-group">
            <label class="col-sm-1 control-label">头像:</label>
            <div class="col-sm-4">
                <div class="input-group ">
                    <input type="text" id="thumb" name="faceUrl" value="" class="form-control" autocomplete="off">
                    <span class="input-group-btn">
                        <button class="btn btn-default" id="upload" type="button" data-original-title="" title="">选择图片</button>
                    </span>
                </div>
                <img class="config_img thumb" src="/static/images/nopic-107.png" >
            </div>
        </div>



        <div class="form-group js_photos" >
            <label class="col-sm-1 control-label"> 视频文件</label>
            <div class="col-sm-3">
                <input type="radio" name="videoType" lay-filter="videoType" value="1" title="本地上传" checked="">
                <input type="radio" name="videoType" lay-filter="videoType" value="2" title="外部链接">
            </div>
        </div>

        <div class="form-group js_photos" >
            <label class="col-sm-1 control-label"> </label>
            <div class="col-sm-3">

                <div class="input-group type_2">
                    <input type="file" name="" class="do_upload" data-val="path"  style="display: none">
                    <input type="text" class="form-control path" disabled value="" >
                    <span class="group-span-filestyle input-group-btn" tabindex="0">
                                        <label class="btn btn-default id_photos" data-original-title="" title="">
                                            <span class="glyphicon glyphicon-folder-open"></span>
                                            上传
                                        </label>
                                    </span>
                </div>

                <div class="input-group type_1" style="display: none">
                    <input type="text" class="form-control path" name="path"  value="" >
                </div>

            </div>
        </div>


        <div  class="form-group" >
            <label class="col-sm-1 control-label"> 任务认领情况:</label>
            <div class="col-sm-8">
                <textarea id="promise"  style="display: none;"></textarea>
            </div>
        </div>

        <div  class="form-group" >
            <label class="col-sm-1 control-label">任务完成情况:</label>
            <div class="col-sm-8">
                <textarea id="exponent"  style="display: none;"></textarea>
            </div>
        </div>


        <!--图文模型&单页模型-->
<!--        <div class="form-group"  >-->
<!--                <label class="col-sm-1 control-label">简介:</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <textarea id="content"  style="display: none;"></textarea>-->
<!--                </div>-->
<!--        </div>-->



        <div class="form-group">
            <label class="col-sm-1 control-label">状态:</label>
            <div class="col-sm-4">
                {volist name="audit" id="vo"}
                <input type="radio" name="status" lay-filter="status" value="{$key}" title="{$vo}" {if
                       condition="$key eq 1" } checked {/if} >
                {/volist}
            </div>
        </div>


</div>


</form>
</div>
<div class="add_button">

    <div class="form-group">
        <label class="col-sm-1 control-label"></label>
        <div class="col-sm-8">
            <a type="button" class="layui-btn layui-btn-primary" href="{:URL('community/party/index')}?classify_id={$classify_id}">取消</a>
            <button type="button" class="layui-btn" id="newsave">保存</button>


            <!--            <button class="btn btn-primary btn-sm receive" data-id="1" data-title="提示" data-msg="总层数、每层户数保存成功后不能进行二次修改，是否确定保存" data-operation="newsave">保存-->
            <!--            </button>-->

        </div>
    </div>
</div>


<script>

    var classify_id = "{$classify_id}";
    $(".id_photos").click(function () {
        $(this).parent().parent().find(".do_upload").click();
    });

    $('.js_photos').on('change','.do_upload',function(){
        var content = $(this).attr("data-val");
        var formData = new FormData();
        var name = $($(this)).val();
        var files = $($(this))[0].files[0];
        formData.append("file", files);
        formData.append("name", name);
        //另外加的参数
        formData.append("act", "PostImg");
        // var index = layer.msg('正在提交中....');

        $.ajax({
            url: "{:URL('common/upload/textUpload')}",
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            dataType: 'json',
            success:function (res) {
                $("."+content).val(res.path);
                $("."+content).attr("src",res.path);
            }
            ,error:function (res) {
                alert('错误');
            }
        });
    })

    $(function () {
        $(this).find('.modal-dialog').css({
            'width': '1000px'
        });
    });
    var newModal = new yii.modal();

    //文件页面
    $("#upload").click(function () {
        $(newModal.getid()).show();
        newModal.initialization({
            url: "{:URL('common/upload/index')}",
            type: "post",
            data:{
                type:'detail'
            }
        });
    });

    newModal.on("upload",function(data){
        var images = '';
        $(newModal.getid()).find("#data-area .newimages .active img").each(function () {
            images = $(this).attr('src');
            return false
        })
        $(newModal.getid()).hide();
        //$(".modal-backdrop").remove();
        //$('#nowMainProjectDataForm').modal('hide');
        $(newModal.getid()).find(".modal").hide();
        $("#thumb").val(images);
        $(".config_img").attr("src",images)
    });


    newModal.on("community_add", function (data) {
        var id = $(newModal.getid()).find(".js_add").attr("data-id");
        var name = $(newModal.getid()).find(".js_add").attr("data-name");
        $('#community').val(name);
        $('input[name="community_id"]').val(id);
    });


    //关联用户
    $("#user_btn").click(function () {
        newModal.initialization({
            url: "{:URL('common/Common/userList')}",
            type: "post",
            data: {
                type: 'detail'
            }
        });
    });
    newModal.on("user_add", function (data) {
        var id = $(newModal.getid()).find(".js_add").attr("data-id");
        var name = $(newModal.getid()).find(".js_add").attr("data-name");
        $('#user').val(name);
        $('input[name="fans_id"]').val(id);
    });

    layui.use(['form', 'layedit', 'tree', 'util', 'table','laydate'], function () {
        var form = layui.form
            , layer = layui.layer;
        var layedit = layui.layedit;
        var laydate = layui.laydate;
        var tree = layui.tree;
        var util = layui.util;

        //同时绑定多个
        lay('.test-item').each(function(){
            laydate.render({
                elem: this
                ,trigger: 'click'
                ,type: 'date'
            });
        });


        layedit.set({
            uploadImage: {
                url: "{:URL('/common/upload/textUpload')}" //接口url
                ,type: '' //默认post
            }
        });

        var contentIndex = layedit.build('content');
        var promiseIndex = layedit.build('promise');
        var exponentIndex = layedit.build('exponent');

        form.on('radio(videoType)', function (data) {
            var value = data.value;
            if(value == 1){
                $(".type_2").show();
                $(".type_1").hide();
            }else{
                $(".type_1").show();
                $(".type_2").hide();
            }
        });


        var promise = layedit.getContent(promiseIndex);
        var exponent = layedit.getContent(exponentIndex);
        $("#newsave").click(function () {
            var content = layedit.getContent(contentIndex);
            var promise = layedit.getContent(promiseIndex);
            var exponent = layedit.getContent(exponentIndex);
            var data = $("form").serializeArray();
            data.push({name: "content", value: content},{name: "promise", value: promise},{name: "exponent", value: exponent});
            $.ajax({
                type: 'post',
                url: "{:URL('community/Party/doParty')}",
                data: data,
                dataType: 'JSON',
                success: function (res) {
                    if (res.code != 0) {
                        layer.alert(res.msg);
                    } else {
                        window.location.href = "{:URL('community/party/index')}?classify_id="+classify_id;
                    }
                },
                error: function (res) {

                }
            });
        });




        layui.form.render('select');
        form.render();


    });
</script>

</body>
</html>